
import UIKit

class UTBaseViewController: UIViewController {
    
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        self.navigationController?.setNavigationBarHidden(true, animated: animated)
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        setupUI()
    }
    
    func setupUI() {
        view.backgroundColor = .white
    }
    
    ///强制横屏
    func forceOrientationLandscape() {
        if let appdelegate = UIApplication.shared.delegate as? AppDelegate {
            appdelegate.isForceLandscape = true
            print("Set isForceLandscape to true")
            UIDevice.current.setValue(UIInterfaceOrientation.landscapeRight.rawValue, forKey: "orientation")
            UIViewController.attemptRotationToDeviceOrientation()
        }
    }
    
    ///强制竖屏
    func forceOrientationPortrait() {
        if let appdelegate = UIApplication.shared.delegate as? AppDelegate {
            appdelegate.isForceLandscape = false
            print("Set isForceLandscape to false")
            UIDevice.current.setValue(UIInterfaceOrientation.portrait.rawValue, forKey: "orientation")
            UIViewController.attemptRotationToDeviceOrientation()
        }
    }
}
